Skip to content

fix:In scenarios involving languages such as Chinese, Japanese, and K… - #73

Open
yayapoi wants to merge 1 commit into
markmap:masterfrom
yayapoi:fix-transform-language
Open

yayapoi wants to merge 1 commit into
markmap:masterfrom
yayapoi:fix-transform-language

Conversation

@yayapoi

@yayapoi yayapoi commented Jan 12, 2026

Copy link
Copy Markdown

fix:In scenarios involving languages such as Chinese, Japanese, and Korean, for instance, when an a.md file contains links to other local md files in the format of 第一章, clicking on these links fails to open the local md files normally. However, by converting these languages to UTF-8 encoding, the md files can now be opened without issues
1
2

…orean, for instance, when an a.md file contains links to other local md files in the format of [第一章](/第一章/第一章.md), clicking on these links fails to open the local md files normally. However, by converting these languages to UTF-8 encoding, the md files can now be opened without issues
BoosterY added a commit to BoosterY/markmap-vscode that referenced this pull request Apr 25, 2026
Markdown-it percent-encodes non-ASCII characters in link hrefs (e.g.
Chinese/Japanese/Korean filenames). The openFile handler passed these
encoded paths directly to Utils.joinPath, resulting in file-not-found
errors.

Apply decodeURIComponent before constructing the file URI.

Fixes markmap#73
@gera2ld

gera2ld commented Sep 14, 2026

Copy link
Copy Markdown
Member

Thanks for the PR and the detailed screenshots — you've correctly identified the root cause: the webview renders non-ASCII hrefs percent-encoded, so the extension tries to open a file literally named %E7%AC%AC....

Two problems with the current approach, though:

  1. Wrong layer. openFile in src/extension.ts already validates the path via isSafeRelPath(), which calls decodeURIComponent before checking for traversal. Decoding in the webview means the path we validate (decoded twice) and the path we open (decoded once) differ — fragile and easier to get wrong. The fix belongs on the extension side: decode once after validation and pass the decoded path to joinPath. This also fixes local images (![第一章](第一章/x.png)), which are broken by the same double-encoding.

  2. Your example still wouldn't work. [第一章](/第一章/第一章.md) is a link starting with /. Since 0.2.12 we deliberately reject webview-requested paths that resolve to the filesystem root (security hardening). The docs convention here is relative links: [第一章](第一章/第一章.md). (/path links happened to work before 0.2.12, but that was an accident of Uri.joinPath, not intended behavior — we're keeping the rejection.)

Could you rework the fix in src/extension.ts instead — decode the path once in openFile (and ideally localImage) after the isSafeRelPath check, wrapped in try/catch for malformed sequences like 50%-off.md? Happy to help if you hit issues. Otherwise I can take it from here and credit you for the report.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants